Repository navigation
Fix cert renewal signing the PPPK challenge with the wrong private key - #66
Merged
Merged
Conversation
- ClientKeyStore.getPrivateKey(PublicKey) located the matching key entry by alias, then discarded that alias and re-derived it via getCertificateAlias(), which returns the first alias holding the certificate. Where a keystore has the same certificate under more than one alias, this paired the requested certificate with another entry's private key, so the CA could not verify the PPPK response and rejected the renewal with 403. - Pin the Valid from/to display formatter to Locale.UK: British rendering is intended, since we are based in the UK, user would prefer british "Sept"
garaimanoj
requested changes
Oct 9, 2026
garaimanoj
left a comment
Contributor
There was a problem hiding this comment.
Code LGTM.
I would appreciate it if comments could be avoided where possible. If required, a short single-line comment would be sufficient.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes online certificate renewal failing with 403 when the signing key is picked out of a keystore that holds the same certificate under more than one alias.
ClientKeyStore.getPrivateKey(PublicKey)now uses the alias that was matched when scanning for the requested public key, instead of re-deriving it.MainWindowPanelpins the "Valid from / to" display formatter toLocale.UK.Problem
getPrivateKey(PublicKey)walks the keystore aliases, finds the key entry whose certificate matches the requested public key, then discards the alias it just matched and re-derives it:KeyStore.getCertificateAliasreturns the first alias whose entry holds that certificate. If the certificate appears under more than one alias, that need not be the entry that was matched, so the returned private key can belong to a different alias. If the first match happens to be atrustedCertEntry, it has no key at all and the call throwsUnrecoverableKeyException, which the catch block swallows into anullreturn. Either way the renewal request signed the PPPK challenge with the wrong key and the CA rejected it with 403.Original bug introduced in Commit: d362b3f (parent db5c9af)
File: src/uk/ngs/ca/common/ClientKeyStore.java
Before — d362b3f^ (2011-06-16), lines 148-172:
After — d362b3f, lines 147-164:
Fix
aliasdirectly togetKey(alias, PASSPHRASE), so certificate and private key always come from the same keystore entry.getCertificateAliasis no longer used here.Locale.UKso the panel renders identically whatever the host's default locale is (e.g.th-THBuddhist calendar,ar-SA). This string is display only - never parsed, stored or sent - so it does not affect the PPPK challenge on the wire.Test plan
mvn test(CI: temurin JDK 25) - no existing unit test coversClientKeyStore; the changed branch is a single alias lookup.